<?php
	class Thongtinkh_model extends CI_Model{
	
	//-----------Lấy thông tin của khách hàng-------------

		function get_taikhoan($user)
		{
		   $this->db->where("ten_tk",$user);
		   $this->db->where("quyen",2);
		   $this->db->where("trang_thai",1);
		   $data = $this->db->get("taikhoan");
		   return $data->row();

		}
	//-----------Update thông tin khach hang-------------
		public function update_ttkh ($ten_tk, $data)
		{
			$this->db->where("ten_tk",$ten_tk);
			$this->db->where("quyen",2);
		   $this->db->where("trang_thai",1);
			$this->db->update("taikhoan",$data);
		}

	
//-----------Lấy mật khẩu của khach hang-------------

		function get_pass($ten_tk)
		{	
			$this->db->where("ten_tk",$ten_tk);
			$this->db->where("quyen",2);
		   $this->db->where("trang_thai",1);
			$data = $this->db->get("taikhoan");
			return $data->row();
		} 
//-----------Update mật khẩu-------------
		public function change_pass ($ten_tk, $data)
		{   
			$this->db->where("ten_tk",$ten_tk);
			$this->db->where("quyen",2);
		   $this->db->where("trang_thai",1);
			$this->db->update("taikhoan",$data);
		}
//------------Lay lich su dat tour------------
		public function get_lichsudattour($ten_tk)
		{
			$sql = "select ten_tour,ngay_bat_dau,ngay_ket_thuc,gia,phuong_tien,ngay_dat,so_nguoi,dondathang.trang_thai
			from tour,chuyendi,dondathang
			where tour.id_tour = chuyendi.id_tour and chuyendi.id_chuyendi = dondathang.id_chuyendi and tour.trang_thai=1 and dondathang.ten_tk='".$ten_tk."' ";
			//$sql="select * from tour";
			$data = $this->db->query($sql);
			return $data->result_array();
		}
//------------Goi phan hoi------------

		public function insert_phanhoi($data,$ten_tk)
		{
			
			$this->db->insert("phanhoi",$data);
			$this->db->where("ten_tk",$ten_tk);
			return $this->db->insert_id();		
		}
		
	}
?>
	
